package org.example.datastructure.ch2;

public class Joseph {
    public static void main(String[] args) {
        sLinkList a = new sLinkList(0);
        sLinkList p = a;
        int n = 5;
        for(int i=1;i<n;i++){
            p.next = new sLinkList(i);
            p  =p.next;
        }
        p.next = a;
        sLinkList t = a;
        sLinkList w;
        while(t.next!=t){
            w  =t.next;
            t = w.next;
            w.next = t.next;
            System.out.println(t.val);
            t = w.next;
        }
        System.out.println("final: "+t.val);
    }
}
